from car_rental.caw.base_request import BaseRequest


def login(url, test_request, data={"loginname": "admin", "pwd": "123456"}):
    """
    登陆请求
    :param url: 测试环境
    :param test_request: BaseRequest的实例
    :param data: 登陆接口的参数
    :return:
    """

    url =url + "/carRental/login/login.action"
    r = test_request.post(url, data=data)
    return r

if __name__ == '__main__':
    r = login("http://192.168.73.128:8080", BaseRequest(), {"loginname": "admin", "pwd": "123456"})

    print("<p>你好！<span class='userName'>超级管理员</span>, 欢迎登录</p>" in r.text)
    # 断言
    assert '<p>你好！<span class="userName">超级管理员</span>, 欢迎登录</p>' in r.text